Add tests for different arguments given to verify-project
authorCarol (Nichols || Goulding) <carol.nichols@gmail.com>
Sat, 29 Aug 2015 17:14:37 +0000 (13:14 -0400)
committerCarol (Nichols || Goulding) <carol.nichols@gmail.com>
Tue, 1 Sep 2015 01:26:29 +0000 (21:26 -0400)
Right now, only passing --manifest-path a path to a Cargo.toml file
works, but I think not specifying a path and verifying the current
working directory, if it has a Cargo.toml, should work as well for
consistency with all the other commands that optionally take
--manifest-path.

tests/test_cargo_verify_project.rs [new file with mode: 0644]
tests/tests.rs

diff --git a/tests/test_cargo_verify_project.rs b/tests/test_cargo_verify_project.rs
new file mode 100644 (file)
index 0000000..ca75952
--- /dev/null
@@ -0,0 +1,43 @@
+use support::{project, execs, main_file, basic_bin_manifest};
+use hamcrest::{assert_that};
+
+fn setup() {}
+
+fn verify_project_success_output() -> String {
+    r#"{"success":"true"}"#.into()
+}
+
+test!(cargo_verify_project_path_to_cargo_toml_relative {
+    let p = project("foo")
+        .file("Cargo.toml", &basic_bin_manifest("foo"))
+        .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+
+    assert_that(p.cargo_process("verify-project")
+                 .arg("--manifest-path").arg("foo/Cargo.toml")
+                 .cwd(p.root().parent().unwrap()),
+                execs().with_status(0)
+                       .with_stdout(verify_project_success_output()));
+});
+
+test!(cargo_verify_project_path_to_cargo_toml_absolute {
+    let p = project("foo")
+        .file("Cargo.toml", &basic_bin_manifest("foo"))
+        .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+
+    assert_that(p.cargo_process("verify-project")
+                 .arg("--manifest-path").arg(p.root().join("Cargo.toml"))
+                 .cwd(p.root().parent().unwrap()),
+                execs().with_status(0)
+                       .with_stdout(verify_project_success_output()));
+});
+
+test!(cargo_verify_project_cwd {
+    let p = project("foo")
+        .file("Cargo.toml", &basic_bin_manifest("foo"))
+        .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+
+    assert_that(p.cargo_process("verify-project")
+                 .cwd(p.root()),
+                execs().with_status(0)
+                       .with_stdout(verify_project_success_output()));
+});
index e9c34dfb08896de24c5d1ed83f234adb889f4885..2fa3ebdb4f64b47f22b1fff13080bba73cccbdf0 100644 (file)
@@ -58,6 +58,7 @@ mod test_cargo_rustc;
 mod test_cargo_search;
 mod test_cargo_test;
 mod test_cargo_tool_paths;
+mod test_cargo_verify_project;
 mod test_cargo_version;
 mod test_shell;